/**
 * 数据表admin_info的操作
 */
const BaseService = require('./BaseService');
const md5 = require("md5");
const APPConfig = require("../config/APPConfig");
const PageList = require("../model/PageList");

class CommentInfoService extends BaseService {
    constructor() {
        super();
        this.currentTable = this.tableMap.comment_info;
    }


    async getListByPage({ post_id, pageIndex = 1 }) {
        let [listData, total_count] = await this.createQuery(this.currentTable)
            .equal("comment_info.post_id", post_id)
            .setPageIndex(pageIndex)
            .innerJoin("user_info", "user_info.id=comment_info.user_id")
            .addField("user_info.nick_name")
            .addField("user_info.avatar")
            .orderBy("comment_info.create_at", "desc")
            .getPageAndCount();

        return new PageList(pageIndex, total_count, listData);
    }

}

module.exports = CommentInfoService;